home *** CD-ROM | disk | FTP | other *** search
- /*
- * This source file is part of Vahunz,
- * a tool to make source code un-/more legible.
- *
- *--------------------------------------------------------------------------
- *
- * Vahunz and the Ugly library are Copyright (C) 1998 by
- * Thomas Aglassinger <agi@giga.or.at>
- *
- * All rights reserved.
- *
- * Refer to the manual for more information.
- *
- *--------------------------------------------------------------------------
- *
- * Ubiqx library is Copyright (C) 1991-1998 by
- * Christopher R. Hertel <crh@ubiqx.mn.org>
- *
- * Ubiqx library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- */
- #include <ctype.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <errno.h>
- #include "utypes.h"
- #include "umemory.h"
- #define n7H
- #include "ustring.h"
- int n9B(STRPTR s)
- {
- size_t y4C = strlen(s);
- int ch = 0;
- if (y4C)
- {
- ch = s[y4C - 1];
- }
- else
- {
- ch = 0;
- }
- return ch;
- }
- STRPTR z5J(d9P j1R, STRPTR j5R, ULONG q6U)
- {
- STRPTR c4G = NULL;
- if (j1R)
- {
- #if c6K
- c4G = (STRPTR) n3V(strlen(j1R) + 1, j5R, q6U);
- #else
- c4G = (STRPTR) c8Y(strlen(j1R) + 1);
- #endif
- if (c4G)
- strcpy(c4G, j1R);
- }
- return (c4G);
- }
- STRPTR c8W(STRPTR s)
- {
- STRPTR e4Mf = s;
- if (s)
- for (; *s != '\0'; s++)
- *s = toupper(*s);
- return e4Mf;
- }
- int x9D(d9P s1, d9P s2)
- {
- #define s6K 1
- #if !s6K
- int z3L;
- #endif
- unsigned char c1, c2;
- size_t i = 0;
- do
- {
- c1 = toupper(s1[i]);
- c2 = toupper(s2[i]);
- i++;
- }
- while (c1 && c2 && (c1 == c2));
- #if s6K
- return (c2 - c1);
- #else
- if (c1 < c2)
- z3L = -1;
- else if (c1 > c2)
- z3L = +1;
- else
- z3L = 0;
- return (z3L);
- #endif
- }
- int k4G(d9P s1, d9P s2, size_t n)
- {
- int z3L;
- unsigned char c1, c2;
- size_t i = 0;
- do
- {
- c1 = toupper(s1[i]);
- c2 = toupper(s2[i]);
- i++;
- }
- while (c1 && c2 && (c1 == c2) && (i < n));
- if (c1 < c2)
- z3L = -1;
- else if (c1 > c2)
- z3L = +1;
- else
- z3L = 0;
- return (z3L);
- }
- STRPTR x9H(d9P s1, d9P s2)
- {
- const char *c1;
- const char *c2;
- do
- {
- c1 = s1;
- c2 = s2;
- while (*c1 != '\0' && (toupper(c1[0]) == toupper(c2[0])))
- {
- c1++;
- c2++;
- }
- if (*c2 == '\0')
- {
- return (char *) s1;
- }
- }
- while (*s1++ != '\0');
- return NULL;
- }
- void p9Nq(STRPTR s, STRPTR j5R, ULONG q6U)
- {
- #if c6K
- u6K(s, j5R, q6U);
- #else
- l5D(s);
- #endif
- }
- void a8W(STRPTR * j1R, d9P c4G, STRPTR j5R, ULONG q6U)
- {
- #if c6K
- p9Nq(*j1R, j5R, q6U);
- *j1R = z5J(c4G, j5R, q6U);
- #else
- l5D(*j1R);
- *j1R = e0O(c4G);
- #endif
- }
- STRPTR w2Y(const char ch)
- {
- static char l1N[2];
- l1N[0] = ch;
- l1N[1] = '\0';
- return l1N;
- }
- STRPTR v9P(d9P str, d9P set)
- {
- size_t i;
- STRPTR result = NULL;
- if (str)
- {
- i = strlen(str) - 1;
- while ((i) && (strchr(set, str[i]) == NULL))
- i--;
- if (strchr(set, str[i]))
- result = (STRPTR) & (str[i]);
- }
- return result;
- }
- BOOL o0Mj(STRPTR s, LONG * num)
- {
- BOOL h5P = FALSE;
- errno = 0;
- *num = strtol(s, NULL, 10);
- if (errno == 0)
- {
- h5P = TRUE;
- }
- return h5P;
- }
- STRPTR q0Qx(LONG num)
- {
- static char q0Kd[10];
- STRPTR u0Ct = NULL;
- if (sprintf(q0Kd, "%d", (int) num))
- {
- u0Ct = q0Kd;
- }
- return u0Ct;
- }
- LONG r1N(STRPTR str, STRPTR set, char q0Qt, BYTE m2M)
- {
- STRPTR s = e0O(set);
- LONG y0O = 0;
- if (s)
- {
- STRPTR l7F = strtok(s, w2Y(q0Qt));
- LONG count = 1;
- while (!y0O && l7F)
- {
- if (m2M & k2S)
- {
- if (!x9D(str, l7F))
- y0O = count;
- }
- else if (!strcmp(str, l7F))
- y0O = count;
- count++;
- l7F = strtok(NULL, w2Y(q0Qt));
- }
- y8Mj(s);
- }
- else
- y0O = -1;
- return (y0O);
- }
-